/**
 * AgaEngine (c)2011.
 * FileName:PhysicEngine.java
 */
package aga.engine.physic;

import java.util.ArrayList;

import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.dynamics.FixtureDef;
import org.jbox2d.dynamics.World;


/**
 * 
 * @author User
 */
public class PhysicEngine {
    //===========================================================
    //Constants
    //===========================================================

    //===========================================================
    //Fields
    //===========================================================
    private ArrayList<PhysicBody> physicsArr = new ArrayList<PhysicBody>();
    private World world;
    private float dt = 1f / 30f;
    private int vIterations = 8;
    private int pIterations = 8;

    //===========================================================
    //Constructors
    //===========================================================
    public PhysicEngine(Vec2 gravity, boolean doSleep) {
        world = new World(gravity, doSleep);
    }

    //===========================================================
    //Getter & Setter
    //===========================================================

    //===========================================================
    //Methods for/from SuperClass/Interfaces
    //===========================================================
    public void tick() {
        world.step(dt, vIterations, pIterations);
        //Log.v("PE  tick", "world step");
    }

    //===========================================================
    //Methods
    //===========================================================

    public Rectangle createRectangle(float x, float y, float halfWidth,
            float halfHeight, float density, float friction, float restitution, BodyType bt, int color) {
        return new Rectangle(world, x, y, halfWidth, halfHeight, density,
                friction, restitution, bt, color);
    }

    public Rectangle createRectangle(float x, float y, float halfWidth,
            float halfHeight, float density, float friction, float restitution) {
        return new Rectangle(world, x, y, halfWidth, halfHeight, density,
                friction, restitution, BodyType.DYNAMIC, 0);
    }

    public JointRevolute createJointRevolute(Body b1, Body b2) {
        return new JointRevolute(world, b1, b2);
    }

    public JointPrismatic createJointPrismatic(Body b1, Body b2) {
        return new JointPrismatic(world, b1, b2);
    }

    public void addPhysicObjects() {

    }
    //===========================================================
    //Inner and Anonymous Classes
    //===========================================================
}
